﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Jayden.Dll.InformationProvider.WorldBank;
using Jayden.Dll.Web.Json;
using System.IO;

namespace InformationProviderTest
{
	class Program
	{
		static void Main(string[] args)
		{
			if (!Directory.Exists("cache"))
				Directory.CreateDirectory("cache");

			WorldBankDataProvider provider = new WorldBankDataProvider();
			string[] indicators = new string[] { "EN.ATM.CO2E.PC", "SP.POP.TOTL", "EN.ATM.CO2E.KT", "SP.POP.GROW", "EG.USE.ELEC.KH.PC", "GC.DOD.TOTL.GD.ZS" };
			string countries = "fr;be;de;es;gr;nl;gb;au;us;cn;wld";
			for (int c = 0; c < indicators.Length; c++)
			{
				List<CountryIndicatorValue> values = new List<CountryIndicatorValue>(provider.Get(countries, indicators[c]));
				foreach (CountryIndicatorValue ciValue in values)
				{
					Country country = provider.GetCountry(ciValue.CountryIsoCode);
					Indicator indicator = provider.GetIndicator(ciValue.IndicatorId);
					Console.WriteLine("{1} for {0} is {2} in {3}.", country, indicator, ciValue.Value, ciValue.Date);
				}
				CountryIndicatorTable table = new CountryIndicatorTable(provider, values);
				table.SaveTsv(indicators[c] + ".tsv");
			}
		}
	}
}
